import { Block,View,Text } from '@tarojs/components'
import { useSelector } from 'react-redux'
import { CardTypeTmpl } from './CardType'

import './cardheader.less'

function CardHeader({ card }) {
  console.log('CardHeader',CardHeader);
  const __authorizePhoneStatus = useSelector(state => state.userInfo.__authorizePhoneStatus);

  function handleAddPhoneContact(){

  }
  return (
    <View className='card-body'>
      { card && __authorizePhoneStatus &&  <CardTypeTmpl card={card} __authorizePhoneStatus={__authorizePhoneStatus} />}
      {/*  名片操作  */}
      <View className='card-options'>
        {card.cardForwardStatus === 0 && (
          <Block>
            <View className='options right-options'>
              <Text className='iconfont icon-icon_Share'></Text>分享名片
                  {/* <LoginButton
                onLogined={this.showShareModal}
                userInfo={__userInfo}
              ></LoginButton> */}
            </View>
            <View className='center'></View>
          </Block>
        )}
        {__authorizePhoneStatus&& __authorizePhoneStatus.authorizeStatus !== 1 ? (
          <View className='options left-options'>
            <Text className='iconfont icon-phonebook_fill'></Text>
                交换联系方式
            {/* {!__userInfo.isAuthUserInfo ? (
              <LoginButton
                onLogined={this.handleAuthForExchange}
                data-from='userinfo'
                userInfo={__userInfo}
              ></LoginButton>
            ) : __authorizePhoneStatus.authorizeStatus !== 1 ? (
              <CoverForm
                type={3}
                data-from='phone'
                onPhoneauthcomplete={this.handleAuthForExchange}
              ></CoverForm>
            ) : (
              <CoverForm onSubmit={this.handleAuthForExchange}></CoverForm>
            )} */}
          </View>
        ) : (
          <View
            className='options left-options'
            onClick={handleAddPhoneContact}
          >
            <Text className='iconfont icon-phonebook_fill'></Text>
                存入手机通讯录
          </View>
        )}
      </View>
    </View>
  )
}

export { CardHeader }